USE [texchange_db]
GO

/****** Object:  UserDefinedFunction [dbo].[Fn_GetUniversalTypeById]    Script Date: 05/29/2011 20:00:19 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[Fn_GetUniversalTypeById] 
(	
	-- Add the parameters for the function here
	@id  bigint=0,
	@language_id bigint = 0
)
RETURNS TABLE 
AS
RETURN 
(
	-- Add the SELECT statement with parameter references here
	SELECT [UniversalType].[id], [UniversalType].[name], [UniversalType].[language_id], [UniversalType].[type_id], 
	[UniversalType].[isActive],[UniversalType].[parent_id], utype.name as parent_name from UniversalType
	LEFT JOIN UniversalType as utype on utype.id=UniversalType.parent_id
	 WHERE UniversalType.id=@id AND UniversalType.language_id=@language_id
)
GO


